// packageD/quickPay/member_add_bank_first/member_add_bank_first.js
let app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    name: "",
    num: "",
    bank: [],
    info: {},
    status: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.initData();
    this.getInfo();
    this.getBank();
    this.setData({
      order_pay_id: options.order_pay_id,
    });
    if(options.status) {
      this.setData({
        status: options.status,
      });
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  numInp(e) {
    let val = e.detail.value;
    this.setData({
      num: val,
    });
  },
  initData() {
    this.setData({
      name: "",
      num: "",
      bank: [],
      info: {},
    });
  },
  getBank() {
    let that = this;
    let urlStr = app.getNetAddresss(
      "plugin.converge_pay.frontend.controllers.quick-pay-bank-card.index"
    );
    app._getNetWork({
      url: urlStr,
      showToastIn: false,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            bank: res.data,
          });
        } else {
          that.setData({
            bank: res.data,
          });
        }
      },
      fail: function (res) {
        console.log(res.msg);
      },
    });
  },
  next() {
    if (app._isTextEmpty(this.data.num)) {
      wx.showToast({
        icon: "none",
        title: "请输入卡号",
        duration: 1500,
      });

      return;
    }
    wx.navigateTo({
      url:
        "/packageD/quickPay/add_bank_second/add_bank_second?card_no=" +
        this.data.num +
        "&order_pay_id=" +
        this.data.order_pay_id+'&status='+this.data.status,
    });
  },
  getInfo() {
    let that = this;
    let urlStr = app.getNetAddresss(
      "plugin.converge_pay.frontend.controllers.quick-pay-bank-card.get-payer-info"
    );
    app._getNetWork({
      url: urlStr,
      showToastIn: false,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          that.setData({
            info: res.data,
          });
        }
      },
      fail: function (res) {
        console.log(res.msg);
      },
    });
  },
});
